function $( id ){
	return document.getElementById( id );
}

/* 去前后空格 */
function Trim(str){ 
	return str.replace(/(^\s*)|(\s*$)/g,""); 
}

/* 手机校验 */
function egrMobileCheck(in_mobile){
	var reg=new RegExp(/^[0]?1\d{10}$/ig);
	if(!reg.test(in_mobile)){
		return false;
	}
	return true;
}

/* 邮件校验 */
function checkMail(in_email){
	reg = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
	if(!(reg.test(in_email))){
		return false;
	}
	return true;
}

function check_number(objvalue){
	patten = /^\d+$/;
	return patten.test(objvalue);   
}



function getRadioValueByName(radioname)
{
	var readioValue = 0;
	var radioArray = document.getElementsByName(radioname);
	for(var i=0;i< radioArray.length;i++){
		if( radioArray[i].checked==true){
			readioValue = radioArray[i].value;
			break;
		}
	}
	return readioValue;
}

function setRadioValueByName(radioname,newValue)
{

	var radioArray = document.getElementsByName(radioname);
	for(var i=0;i< radioArray.length;i++){
		if( radioArray[i].value==newValue){
			radioArray[i].checked = true;
		}else{
			radioArray[i].checked = false;
		}
	}
	return;
}



var tempObj;
function fEvent(sType,oInput){
	switch (sType){
		case "focus" :
			oInput.isfocus = true;
		case "mouseover" :
			oInput.style.borderColor = '#9ecc00';
			break;
		case "select":
			oInput.select();
			oInput.isfocus = true;
			break;
		case "blur" :
			oInput.isfocus = false;
		case "mouseout" :
			if(!oInput.isfocus){
				oInput.style.borderColor='#C2C2C2';
			}
		break;
	}
}


function SetAllInput(){
	var temp,tempValue=null;
    tempObj = document.getElementsByTagName("INPUT");
	for(var i=0; i<tempObj.length; i++){
		if(tempObj[i].type=="text"){
			if(tempObj[i].onfocus == null){	
				tempValue = tempObj[i].value;
				tempObj[i].onfocus = new Function("fEvent('focus',tempObj["+i+"])");
			}
				
			if(tempObj[i].onblur == null)
				tempObj[i].onblur = new Function("fEvent('blur',tempObj["+i+"])");				

			if(tempObj[i].onmouseover == null)
				tempObj[i].onmouseover = new Function("fEvent('mouseover',tempObj["+i+"])");
				
			if(tempObj[i].onmouseout == null)
				tempObj[i].onmouseout = new Function("fEvent('mouseout',tempObj["+i+"])");
				
			if(tempObj[i].onclick == null)
				tempObj[i].onclick = new Function("tempObj["+i+"].select();");
			
			if(tempObj[i].onchange == null){
				if(tempValue != null)
					tempObj[i].onchange = new Function("if(tempObj["+i+"].value!='"+tempValue+"') {tempObj["+i+"].style.color='#333333';}else{tempObj["+i+"].style.color='#666666';}");		
			}				
		} 
	}
}

function SetUserInput(){
	var temp,tempValue=null;
    tempObj = document.getElementsByTagName("INPUT");
	for(var i=0; i<tempObj.length; i++){
		if(tempObj[i].type=="text"){
			if(tempObj[i].onfocus == null){	
				tempValue = tempObj[i].value;
				tempObj[i].onfocus = new Function("fEvent('focus',tempObj["+i+"])");
			}
				
			if(tempObj[i].onblur == null)
				tempObj[i].onblur = new Function("fEvent('blur',tempObj["+i+"])");				

				
			if(tempObj[i].onmouseover == null)
				tempObj[i].onmouseover = new Function("fEvent('mouseover',tempObj["+i+"])");
			if(tempObj[i].onmouseout == null)
				tempObj[i].onmouseout = new Function("fEvent('mouseout',tempObj["+i+"])");
			if(tempObj[i].onclick == null)
				tempObj[i].onclick = new Function("tempObj["+i+"].focus();");
			
			if(tempObj[i].onchange == null){
				if(tempValue != null)
					tempObj[i].onchange = new Function("if(tempObj["+i+"].value!='"+tempValue+"') {tempObj["+i+"].style.color='#333333';}else{tempObj["+i+"].style.color='#666666';}");		
			}
		} 
	}
}

function CheckInputSearchForaddform(){//请输入想查询的关键字
	if(Trim(document.addform.keyword.value)=="" || Trim(document.addform.keyword.value)=="请输入关键字" || Trim(document.addform.keyword.value)=="请输入想查询的关键字"){
		alert("请输入想查询的关键字");
		document.addform.keyword.select();
		return false;
	}
	document.addform.submit();
	return false;
}

function CheckInputSearchAddFormFoot(){//请输入想查询的关键字
	if(Trim(document.addformFoot.keyword.value)=="" || Trim(document.addformFoot.keyword.value)=="请输入想查询的关键字"){
		alert("请输入想查询的关键字");
		document.addformFoot.keyword.select();
		return false;
	}
	document.addformFoot.submit();
	return false;
}



function CheckInputSearchForTimeForm(){
	if(Trim(document.complexform.dest.value)=="" || Trim(document.complexform.dest.value)=="中文/拼音"){
		alert("请输入想查询的目的地");
		document.complexform.dest.select();
		return false;
	}
	document.complexform.submit();
	return false;

}

lineListInit = function( className ){
	if(!className){
		className="m4line_border"	
	}
	var tempArrayObj = document.getElementsByTagName("TABLE");
	for( var index=0; index<tempArrayObj.length; index++ ){
		var tempTrArrayObj = tempArrayObj[index].getElementsByTagName("TR");
		for( var i=0; i<tempTrArrayObj.length; i++ ){
			if( tempTrArrayObj[i].className==className ){
				tempTrArrayObj[i].onmouseover = function(){
					var tempTdArrayObj = this.getElementsByTagName("td");
					for( var j=0; j<tempTdArrayObj.length; j++ ){
						tempTdArrayObj[j].style.background="#FFFFE8";
					}
				}
				tempTrArrayObj[i].onmouseout = function(){
					var tempTdArrayObj = this.getElementsByTagName("td");
					for( var j=0; j<tempTdArrayObj.length; j++ ){
						tempTdArrayObj[j].style.background="#ffffff";
					}
				}			
			}
		}
	}
	return;
}

function DisplayDate(){
    var now = new Date();//当前时间
	function getThisMonth(){ //这个月日期
	    return now.getFullYear()+"-"+(now.getMonth()+1)+"-"+now.getDate();
	}
	function getNextMonth(){ //下个月日期
        var d=new Date(now.getFullYear(),now.getMonth()+1,now.getDate());
		return d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
    }
	document.getElementById('dateA').value=getThisMonth();
	document.getElementById('dateB').value=getNextMonth();
}

/*
var newSS=document.createElement('link');
newSS.rel='icon';
newSS.type='image/x-icon';
newSS.href=escape("/images/favicon.ico");
newSS.href=escape("http://www.google.cn/favicon.ico");
document.getElementsByTagName("head")[0].appendChild(newSS);
newSS.rel='shortcut icon';
document.getElementsByTagName("head")[0].appendChild(newSS);
newSS.rel='Bookmark';
document.getElementsByTagName("head")[0].appendChild(newSS);
*/

/* 加入收藏夹 */
function setHome(title, url) {   
    if(!title) {   
        var title = window.document.title;   
    }   
    if(!url) {   
        var url = window.document.location;   
    }   
    try{   
        if (document.all){    
            window.external.addFavorite(url,title);    
        } else if (window.sidebar) {    
            window.sidebar.addPanel(title, url,"");    
        }    
    }catch(e){};   
}




var lastScrollY=0; 
function heartBeat(){  
var diffY; 
if (document.documentElement && document.documentElement.scrollTop) 
    diffY = document.documentElement.scrollTop; 
else if (document.body) 
    diffY = document.body.scrollTop 
else 
    {/*Netscape stuff*/} 
     
//alert(diffY); 
percent=.1*(diffY-lastScrollY);  
if(percent>0)percent=Math.ceil(percent);  
else percent=Math.floor(percent);  
document.getElementById("lovexin12").style.top=parseInt(document.getElementById ("lovexin12").style.top)+percent+"px"; 
document.getElementById("lovexin14").style.top=parseInt(document.getElementById ("lovexin12").style.top)+percent+"px"; 
lastScrollY=lastScrollY+percent;  
//alert(lastScrollY); 
} 


var abroad = 1;
var around = 3;
var domestic = 2;
var vacation = 6;
var hongkong = 4;
var visa = -1;
var company = 6;
var destination = 7;
var vacation = 5;

/*
	使用的ajxa方法统一， 可重复使用
		_url  传递的url地址
		_method 使用方法 post or get 暂时支持 get
		_send 发送的内容 如 a=1&b=2 urlencode
		returnfuc 完成后调用的方法， 一个参数 返回的字符串
	
*/

function axajObj(){
	this.xmlHttpObj = null;
	this.returnFuc = function(val){};
}

axjaReturnFuc = function(value){}
axajSend = function( _url, _method, _send, returnFuc ){
	if(!returnFuc)
		returnFuc = axjaReturnFuc;
	var xmlHttpObj;
    if(window.ActiveXObject){
        xmlHttpObj = new ActiveXObject("Microsoft.XMLHTTP");
    }else if(window.XMLHttpRequest){
        xmlHttpObj = new XMLHttpRequest();
    }
    try{
        xmlHttpObj.onreadystatechange = function(){
			if(xmlHttpObj.readyState == 4)
			{            
				if (xmlHttpObj.status == 200 )
				{
					returnFuc( xmlHttpObj.responseText );
				}
			}	
		};
       	xmlHttpObj.open(_method, _url, true);
       	xmlHttpObj.send(_send);
    }catch(exception){
        alert("xmlHttp Fail");
    }
	return;	
}

locationSetting = function(){
	var url = escape(window.location.href.toString());
	var referrer = escape(document.referrer);
	if(referrer==""){
		return;
	}

	var patrn1=/\.(baidu|google)\./gi; 
	if ( patrn1.test(referrer) ){
		var urlString = "referrer="+referrer+"&url="+url;
		//axajSend( "/PageStatistics/record.php?"+urlString, "GET", "" );
		var div = null;
		div = document.createElement("div");
		div.style.display = "none";
		div.innerHTML = '<iframe MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 SCROLLING=no src=/PageStatistics/record.php?'+urlString+' height=0 width=0></iframe>';
		document.body.appendChild(div);
	}
	return;
}

function HtmlInitFuc(fuc){
	if(window.document.all){
		window.attachEvent("onload" ,
			function(e){
				fuc();
			}
		);
	}else{
		window.addEventListener("load",
			function(e){
				fuc();
			},
			false
		);
	}	
	return;
}
HtmlInitFuc(locationSetting);

/* 订单数量及咨询数量 */
showIncallNum = function(){
	document.write(incallNum);
}
showOrderNum = function(){
	document.write(orderNum);
}

/* about nav */
var aboutNavWhere = -1;
function ShowAboutNav(){
	if(aboutNavWhere=="-1") return; 
	var a = document.getElementById('aboutNav').getElementsByTagName("LI");
	if(aboutNavWhere<a.length){
		a[aboutNavWhere].className = "current";
	}
	return;
}



var initObjArray = {};
function InitForm( formName , newClassName ){
	var formObj = $(formName);
	if(!formObj)
		return;
		
    var tempObjArray = formObj.getElementsByTagName("INPUT");
	for(var i=0; i<tempObjArray.length; i++){
		if( tempObjArray[i].type=="text" ||tempObjArray[i].type=="password" ){
				
			initObjArray[tempObjArray[i].name] = {
				"oldonfocus" : tempObjArray[i].onfocus,
				"oldonblur" : tempObjArray[i].onblur,
				"oldClassName" : tempObjArray[i].className,
				"newClassName" : newClassName
			}
			if(typeof tempObjArray[i].onfocus != 'function'){
				tempObjArray[i].onfocus = function(){
					this.className = initObjArray[this.name]["newClassName"];	
				};
			}else{
				tempObjArray[i].onfocus = function(){
					this.className = initObjArray[this.name]["newClassName"];
					initObjArray[this.name]["oldonfocus"]();
				}
			}
			
			if(typeof tempObjArray[i].onblur != 'function'){
				tempObjArray[i].onblur = function(){
					this.className = initObjArray[this.name]["oldClassName"];
				};
			}else{
				tempObjArray[i].onblur = function(){
					this.className = initObjArray[this.name]["oldClassName"];
					initObjArray[this.name]["oldonblur"]();
				}
			}
			
		}
	}
	return;
}



/* 显示层 */
function showDivBoxObj(){
	this.div = null;								//显示层
	this.divClassName = null;						//显示层
	this.selectObj = null;							//目标元素
	return;
}

showDivBoxObj.prototype.showDiv = function(content, obj){
	if(this.div==null){		
		this.div=document.createElement('DIV');
		this.div.style.display='none';
		this.div.style.position='absolute';
		this.div.className = this.divClassName;
		var bs = document.getElementsByTagName('BODY');
		bs[0].appendChild(this.div);
	}
	this.selectObj = obj;
	this.ShowWhere();
	this.div.innerHTML = content;
	this.div.style.display='';
	return;
}

showDivBoxObj.prototype.hideDiv = function(){
	if(this.div	== null) 
		return;
	this.div.style.display='none';
	return;
}

showDivBoxObj.prototype.ShowWhere = function(){
	var OBTop=0;
	var OBLeft=0;
	var OBWidth=0;
	var OBHeight=0;

	var oCurrentNode = this.selectObj;
	while(oCurrentNode != null && oCurrentNode.tagName != "BODY"){
		OBTop += oCurrentNode.offsetTop;
		OBLeft += oCurrentNode.offsetLeft;
		oCurrentNode = oCurrentNode.offsetParent;
	}

	OBTop += document.getElementsByTagName('BODY')[0].offsetTop 
	OBLeft += document.getElementsByTagName('BODY')[0].offsetLeft 
	
	this.div.style.top = (OBTop + 0 + this.selectObj.offsetHeight + "px");
	this.div.style.left = (OBLeft  + 0 + "px");
	return;
}


addOnloadFuc = function(fuc){
	if(window.document.all){
		window.attachEvent("onload" ,
			function(e){
				fuc()
			}
		);
	}else{
		window.addEventListener("load",
			function(e){
				fuc()
			},
			false
		);
	}
	return;
}

/*
	使用的ajxa方法统一， 可重复使用
		_url  传递的url地址
		_method 使用方法 post or get 暂时支持 get
		_send 发送的内容 如 a=1&b=2 urlencode
		returnfuc 完成后调用的方法， 一个参数 返回的字符串
*/

ajxaReturnFuc = function(value){}
ajxaSend = function( _url, _method, _send, returnFuc ){
	if(!returnFuc)
		returnFuc = axjaReturnFuc;
	var xmlHttpObj;
    if(window.ActiveXObject){
        xmlHttpObj = new ActiveXObject("Microsoft.XMLHTTP");
    }else if(window.XMLHttpRequest){
        xmlHttpObj = new XMLHttpRequest();
    }
    try{
        xmlHttpObj.onreadystatechange = function(){
			if(xmlHttpObj.readyState == 4){            
				if (xmlHttpObj.status == 200 ){
					returnFuc( xmlHttpObj.responseText );
				}
			}	
		};
		xmlHttpObj.open(_method, _url, true);
		xmlHttpObj.setRequestHeader('Content-type','application/x-www-form-urlencoded');
       	xmlHttpObj.send(_send);
    }catch(exception){
        alert("xmlHttp Fail");
    }
	return;	
}


/* 首页初始化*/
doUserLogin = function(){
	if( $("username").value=="" || $("username").value=="手机号/邮箱" ){
		alert("请输入您的登陆的帐号;")
		$("username").focus();
		return false;
	}
	if( $("passwd").value==""){
		alert("请输入您的密码;")
		$("passwd").focus();
		return false;
	}
	$("formLogin").submit();
	return false;	
};

webIndexInit = function(){
	var loadingString = '';
	loadingString += '<div id="rtext_title"><h3>会员登录</h3></div>';
	loadingString += '<form action="/users/login-action.php" id="formLogin" name="formLogin"  method="post">';
	loadingString += '<input type="hidden" name="goBackUrl" id="goBackUrl" value="/" />';
	loadingString += '<ul>';
	loadingString += '<li>账户：<input type="text" name="username" id="username" value="会员卡号/手机号/邮箱" maxlength="50" /></li>';
	loadingString += '<li>密码：<input type="password" name="passwd" id="passwd" maxlength="14" /></li>';
	loadingString += '<li style="padding-bottom:0px;"><span><a href="#" onclick="return doUserLogin();"><img src="img/bt2s.gif" /></a></span></li>';
	loadingString += '<li><span><a href="/users/register.php">注册新会员</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="/users/GetPass.php">忘记密码?</a></span></li>';
	loadingString += '</ul>';
	loadingString += '</form>';
	loadingString += '<div id="rtext_border_l"></div><div id="rtext_border_r"></div><div id="rtext_border_bl"></div><div id="rtext_border_br"></div>';

	if( !checkLoginIf() ){
		$("loginload").innerHTML = loadingString;
	}else{
		var _url = "/users/userLoginStatus.php?rnd="+new Date(), _send = null, _method = "get";
		returnFuc = function(returnString){
			if(returnString!="0"){
				$("loginload").innerHTML = returnString;
				$("loginload").style.height = "145px";
			}else{
				$("loginload").innerHTML = loadingString;
			}
			return;
		}
		axajSend( _url, _method, _send, returnFuc );
	}
	try{
		$("username").onfocus = function(){
			if(this.value=="手机号/邮箱") this.value='';
			this.className = "loginloadinput";
		};
		$("username").onblur = function(){
			if(this.value=="") this.value='手机号/邮箱';
			this.className = "";
		};
		
		$("passwd").onfocus = function(){
			this.className = "loginloadinput";
		};
		$("passwd").onblur = function(){
			this.className = "";
		};
		$("passwd").onkeyup = $("username").onkeyup = function(event){
			event=event?event:(window.event?window.event:null);
			var kc=event.keyCode;
			if(kc==13){
				doUserLogin();
			}
			return;
		}	
	}catch(e){}
	
	return;	
}